﻿<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>OA管理系统</title>
    <link rel="stylesheet" href="assets/css/style.css">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, width=device-width">
    <meta name="description" content="Bitter Mobile Template">
    <meta name="keywords" content="bootstrap, mobile template, cordova, phonegap, mobile, html, responsive" />
    <script src="assets/js/lib/jquery-3.4.1.min.js"></script>
</head>

<body>

    <!-- Page loading -->
    <div class="loading">
        <div class="spinner-grow"></div>
    </div>
    <!-- * Page loading -->
    <!-- App Header -->
    <div class="appHeader">
        <div class="left">
            <a href="javascript:;" class="icon goBack">
                <i class="icon ion-ios-arrow-back"></i>
            </a>
        </div>
        <div class="pageTitle">销假</div>

    </div>
    <!-- * App Header -->
    <!-- App Capsule -->
    <div id="appCapsule">

        <div class="appContent" id="listBack">

            <div class="card border-primary mb-3" style="max-width: 20rem;" >
                <div class="card-body">
                    <h4 class="card-title">无待销假</h4>
                </div>

<!--            </div>-->

        </div>



        <!-- * Sidebar Menu -->
        <!-- ///////////// Js Files ////////////////////  -->
        <!-- Jquery -->

        <!-- Bootstrap-->
        <script src="assets/js/lib/popper.min.js"></script>
        <script src="assets/js/lib/bootstrap.min.js"></script>
        <!-- Owl Carousel -->
        <script src="assets/js/plugins/owl.carousel.min.js"></script>
        <!-- Main Js File -->
        <script src="assets/js/app.js"></script>

        <script type="text/javascript">
            $(function () {
                $.ajax({
                    url: "/OASystem/leave/backLeave",
                    dataType: "json",
                    type: "get",
                    success: function (data) {
                        console.log(data)
                        var str = ""
                        $(data.data).each(function (index,item) {
                            str +='<div class="card border-primary mb-3" style="max-width: 20rem;" >\n'+
                                '<div class="card-header"> <button type="button" class="btn btn-success" onclick="xiaojia('+item.id+')" >销假</button></div>\n' +
                                '                <div class="card-body">\n' +
                                '                    <h4 class="card-title">'+item.start+"———"+item.end+'</h4>\n' +
                                '                    <p class="card-text">'+item.leaveReason+'</p>\n' +
                                '                </div>'+'</div>'
                        })
                        $('#listBack').html(str)

                        if (data.data.length == 0){
                            var c = '<div class="card border-primary mb-3" style="max-width: 20rem;" >\n' +
                                '                <div class="card-body">\n' +
                                '                    <h4 class="card-title">无待销假</h4>\n' +
                                '                </div>\n' +
                                '\n' +
                                '            </div>'
                            $('#listBack').html(c)
                        }

                    },
                    error: function (err) {
                        alert("服务器出错");
                    }
                });
            })


            function xiaojia(id) {
                $.ajax({
                    url: "/OASystem/leave/dealVaction",
                    dataType: "json",
                    data: {"id":id},
                    type: "get",
                    success: function (data) {
                        if (data.code == 200){
                            alert("销假成功")
                        }else {
                            alert("销假失败")
                        }
                        window.location.reload();
                    },
                    error: function (err) {
                        alert("服务器出错");
                    }
                });
            }
        </script>


</body>

</html>